home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / ARMLINUX / MAIL / 9804 / 000057_owner-linux-arm…r.rutgers.edu _Fri Apr 17 07:54:29 1998.msg < prev    next >
Internet Message Format  |  1998-05-13  |  5KB

  1. Return-Path: <owner-linux-arm-outgoing@vger.rutgers.edu>
  2. Received: from orava.funet.fi (orava.funet.fi [128.214.248.46])
  3.     by odie.barnet.ac.uk (8.8.6/8.8.6) with ESMTP id HAA23708
  4.     for <willy@odie.fluff.org>; Fri, 17 Apr 1998 07:54:28 +0100
  5. Received: from vger.rutgers.edu ([128.6.190.2]:28833 "EHLO vger.rutgers.edu" ident: "root") by orava.funet.fi with ESMTP id <391239-13857>; Fri, 17 Apr 1998 09:54:58 +0300
  6. Received: by vger.rutgers.edu id <971031-29197>; Fri, 17 Apr 1998 02:47:48 -0400
  7. Received: from odie.barnet.ac.uk ([194.82.202.98]:11001 "EHLO odie.barnet.ac.uk" ident: "willy") by vger.rutgers.edu with ESMTP id <971026-29197>; Fri, 17 Apr 1998 02:47:41 -0400
  8. Received: (from willy@localhost)
  9.     by odie.barnet.ac.uk (8.8.6/8.8.6) id HAA23693
  10.     for linux-arm@vger.rutgers.edu; Fri, 17 Apr 1998 07:53:17 +0100
  11. From: Matthew Wilcox <willy@odie.barnet.ac.uk>
  12. Message-Id: <199804170653.HAA23693@odie.barnet.ac.uk>
  13. Subject: memfastset.S
  14. To: linux-arm@vger.rutgers.edu
  15. Date:     Fri, 17 Apr 1998 07:53:16 +0100 (BST)
  16. X-Mailer: ELM [version 2.4 PL25]
  17. MIME-Version: 1.0
  18. Content-Type: text/plain; charset=US-ASCII
  19. Content-Transfer-Encoding: 7bit
  20. X-Orcpt: rfc822;linux-arm@vger.rutgers.edu
  21. Sender: owner-linux-arm@vger.rutgers.edu
  22. Precedence: bulk
  23. X-Loop: majordomo@vger.rutgers.edu
  24. Status: RO
  25.  
  26.  
  27. I've optimised Russell's code a bit.  I've changed rather a lot in fact,
  28. but I've stuck to his structure rather than try to work out whether a
  29. 64-byte inner loop would be better, or whether it would make sense to
  30. sacrifice more registers to make the inner loop smaller.  Here's the first
  31. version, which I have tested in BBC BASIC's assembler and then rewritten in
  32. GAS style, so typos may exist though I checked it three times.
  33. It is definitely faster for large blocks of data since I removed an
  34. instruction from the inner loop.  I suspect it to be faster for small
  35. blocks of data as well, but have not tested this hypothesis.
  36.  
  37. /*
  38.  * linux/arch/arm/lib/memfastset.S
  39.  *
  40.  * Copyright (C) 1995, 1996 Russell King
  41.  * Copyright 1998 Matthew Wilcox
  42.  */
  43.  
  44. #include <asm/assembler.h>
  45.         .text
  46. @ Prototype: void memsetl (unsigned long *d, unsigned long c, size_t n);
  47.  
  48.         .global    _memsetl
  49. @ If this is quad-word aligned then Lloop_32 is in one cache line
  50. _memsetl:
  51.         stmfd    sp!, {lr}
  52.         mov    lr, r1
  53.         subs    r2, r2, #16
  54.         blt    Lmod_4
  55.  
  56.         mov    r3, r1
  57.         mov    ip, r1
  58.         subs    r2, r2, #16
  59.         bmi    Lmod_16
  60. Lloop_32:
  61.         stmia    r0!, {r1, r3, ip, lr}
  62.         stmia    r0!, {r1, r3, ip, lr}
  63.         subs    r2, r2, #32
  64.         bge    Lloop_32
  65.  
  66. @        cmn    r2, #32
  67. @        LOADREGS(eqfd, sp!, {pc})
  68. @ at this point, we are up to 28 bytes away from the end of the buffer,
  69. @ r2 is n-32 bytes, ie {-4, -8, ..., -28}; *OR* we've finished and r2
  70. @ contains -32
  71. Lmod_16:
  72.         cmn    r2, #16
  73.         stmgeia    r0!, {r1, r3, ip, lr}
  74.         LOADREGS(eqfd, sp!, {pc})
  75.         addlt    r2, r2, #16
  76.  
  77. @ now we are up to 12 bytes from end of buffer; r2 can be {-4, -8, -12, -16}
  78. Lmod_4:
  79.         adds    r2, r2, #8
  80.         stmgeia    r0!, {r1, lr}
  81. @ -8 & -16 are already done.  If it's non-zero, then it wasn't -8, if
  82. @ it's -16, it won't be taken above 0.
  83.         addnes    r2, r2, #6
  84.         strgt    r1, [r0]
  85.  
  86.         LOADREGS(fd, sp, {pc})
  87.  
  88.  
  89. And here's a completely untested optimisation which I came up with on the
  90. tram on the way into work.  It should improve performance for 16-byte
  91. aligned code.
  92.  
  93.  
  94. /*
  95.  * linux/arch/arm/lib/memfastset.S
  96.  *
  97.  * Copyright (C) 1995, 1996 Russell King
  98.  * Copyright 1998 Matthew Wilcox
  99.  */
  100.  
  101. #include <asm/assembler.h>
  102.         .text
  103. @ Prototype: void memsetl (unsigned long *d, unsigned long c, size_t n);
  104.  
  105.         .global    _memsetl
  106. @ If this is quad-word aligned then Lloop_32 is in one cache line
  107. _memsetl:
  108.         stmfd    sp!, {lr}
  109.         mov    lr, r1
  110.         subs    r2, r2, #16
  111.         blt    Lmod_4
  112.  
  113.         mov    r3, r1
  114.         mov    ip, r1
  115.         subs    r2, r2, #16
  116.         bmi    Lmod_16
  117. Lloop_32:
  118.         stmia    r0!, {r1, r3, ip, lr}
  119.         stmia    r0!, {r1, r3, ip, lr}
  120.         subs    r2, r2, #32
  121.         bge    Lloop_32
  122.  
  123. @        cmn    r2, #32
  124. @        LOADREGS(eqfd, sp!, {pc})
  125. @ at this point, we are up to 28 bytes away from the end of the buffer,
  126. @ r2 is n-32 bytes, ie {-4, -8, ..., -28}; *OR* we've finished and r2
  127. @ contains -32
  128. Lmod_16:
  129.         cmn    r2, #16
  130.         stmgeia    r0!, {r1, r3, ip, lr}
  131.         addlt    r2, r2, #16
  132.  
  133. @ now we are up to 12 bytes from end of buffer; r2 can be {-4, -8, -12, -16}
  134. Lmod_4:
  135.         cmn    r2, #16
  136.  
  137.         LOADREGS(eqfd, sp!, {pc})
  138.         adds    r2, r2, #8
  139.         stmgeia    r0!, {r1, lr}
  140.         strne    r1, [r0]
  141.  
  142.         LOADREGS(fd, sp, {pc})
  143.  
  144. -- 
  145. Set Alias$Case Set Alias$[ |||| |MSet Alias$Otherwise Set Alias$[ \ Matthew
  146. "" |MSet Alias$When If %0=%%0 Then Set Alias$[ "" ||MIf %0=%%0    \ Wilcox
  147. Then Set Alias$Otherwise Set Alias$[ |||||||||||||||| ||MIf       \
  148. %0=%%0 Then Set Alias$When Set Alias$[ ||||||||||||||||
  149. unsubscribe: body of `unsubscribe linux-arm' to majordomo@vger.rutgers.edu